/*
* SMILParser
*
* Version 1.0
*
* Programmers: Jesse Louderback, Noah Pham, Chad Carpenter, and Marc Hindman
*/
package Message;

import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class SMILImage {
	float startTime = 0.0f;
	float endTime = 0.0f;
	private Bitmap bmp;
	protected int xLoc = 0;
	protected int yLoc = 0;
	private String region;
	private String data;

	public SMILImage(SMILObject ob) {
		startTime = ob.startTime;
		endTime = ob.endTime + ob.startTime;
		region = ob.region;
		data = ob.data;
		bmp = getBitmap(data);
	}

	public Bitmap getBitmap(String bitmapUrl) {
		try {
			URL url = new URL(bitmapUrl);
			return BitmapFactory.decodeStream(url.openConnection().getInputStream());
		} catch (Exception ex) {
			return null;
		}
	}

	public float getStartTime() {
		return startTime;
	}

	public void setStartTime(float startTime) {
		this.startTime = startTime;
	}

	public float getEndTime() {
		return endTime;
	}

	public void setEndTime(float endTime) {
		this.endTime = endTime;
	}

	public int getxLoc() {
		return xLoc;
	}

	public void setxLoc(int xLoc) {
		this.xLoc = xLoc;
	}

	public int getyLoc() {
		return yLoc;
	}

	public void setyLoc(int yLoc) {
		this.yLoc = yLoc;
	}

	public Bitmap getBmp() {
		return bmp;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	@Override
	public String toString() {
		return "<img region=\"" + region + "\" src=\"" + data + "\" begin=\""
				+ startTime + "\" dur=\"" + endTime + "\" />";
	}
}
